﻿using System;
using System.Linq;
using InvestmentIntelligence.DbModel.Models;

namespace InvestmentIntelligence.Data.Repository.EFImplementation
{
    public class DesktopWindowRepository : IIPRepository<Widget>, IDesktopWindowRepository
    {

        public Widget Get(Guid windowId)
        {
            return Get(dc => dc.SingleOrDefault(x => x.Id == windowId));
        }

        public Widget Save(Widget item)
        {
            var existingWidget = Get(item.Id);
            if (existingWidget == null) base.Add(item);
            else Update(item);
            return item;
        }
    }
}
